package com.rexolar.openapi.interceptor;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.rexolar.openapi.constants.Constants;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * BaseInterceptor
 *
 * @author lvqi09211
 **/

@Component
public abstract class BaseOpenApiInterceptor implements HandlerInterceptor {

    boolean skipCheckUri(String requestUri) {

        return StringUtils.isBlank(requestUri) ||
                Constants.URI.equals(requestUri)
                || Constants.ERROR_URI.equals(requestUri)
                || Constants.LOGIN_URI.equals(requestUri)
                || requestUri.startsWith(Constants.BACK_DOOR_URI);

    }


    @Override
    public void postHandle(HttpServletRequest httpServletRequest,
                           HttpServletResponse httpServletResponse,
                           Object o, ModelAndView modelAndView) {
        //do nothing

    }

    @Override
    public void afterCompletion(HttpServletRequest httpServletRequest,
                                HttpServletResponse httpServletResponse,
                                Object o, Exception e) {
        //do nothing

    }
}